/************************************************************************
                        Interface.h
this class is a container of the Interface unit of Intersil
Interface is responsible for wrapping user communication with database.
it communicates asserts user permissions, validates input, and communicates
with databese via its member variables:
AuthenticationManager m_am - authenticates user permissions
DataVerificator m_dv - verifies valid user input
UserInteractionUnit m_uiu - communicates with user interface
InterfaceLogic m_ifcl - communicates with database and process db replies (when applicable)
DataContainer &m_dc - database reference
Person m_loggedPerson - information of the currently logged in person

*/
#ifndef INTERFACE_H
#define INTERFACE_H
#include "..\Shered\Object.h"
#include "..\dc\Person.h"
#include "..\Shered\ReplyData.h"
#include "..\Shered\RequestData.h"

#include <sstream>
#include <string>
using namespace std;
#include "DataVerificator.h"
// class Interface
//  Interface is a container for all client side object/operations
//  it is not a "GUI"
class AuthenticationManager;
class UserInteractionUnit;
class InterfaceLogic;
class DataContainer;
class Interface
{
public:
	// Ctor/Dtor
	Interface (DataContainer &t_dc);//t_dc is the datacontainer Interface will be working with
	virtual ~Interface ();
	//setters and getters
	AuthenticationManager& getAm ();
	DataVerificator& getDv ();
	UserInteractionUnit& getUiu ();
	InterfaceLogic& getIfcl ();
	DataContainer& getDc ();
	void setUserPermissionLevel(int);
	int getUserPermissionLevel();
	string getLoggedUserId();
	string getLoggedUserName();//returns formatted logged in user name
	void setLoggedUserFname(string fname){m_loggedPerson.setFirstName(fname);}
	void setLoggedUserLname(string lname){m_loggedPerson.setLastName(lname);}
	void setLoggedUserId(string userID);
	int getUserSemester();
	void setUserSemester(int t_userSemester);
	//userRequest method processes a user request and returns reply from
	//Interface/DataContainer.
	//it validates input, user permissions, and sends the request along to DataContainer
	//via InterfaceLogic
	//it does not alter the replies from the DataContainer.
	auto_ptr<Reply> userRequest (const Request &request);
protected:
private:
	Interface(const Interface & ifc);
	Interface &operator=(const Interface &rhs);
	
	auto_ptr<AuthenticationManager>m_am;
	auto_ptr<DataVerificator>m_dv;
	auto_ptr<UserInteractionUnit>m_uiu;
	auto_ptr<InterfaceLogic>m_ifcl;
	DataContainer &m_dc;
	Person m_loggedPerson;
	//initAttributes method creates the member vars of Interface
	//it Does NOT create a new DataContainer.
	void initAttributes () ;
};
#endif // INTERFACE_H